#ifndef _SQL_POOL_H_
#define _SQL_POOL_H_
#include <oal.h>
#include <mysqlconnect.h>
typedef struct mysql_connect_entry
{
    mysqlconnect *sqlconnect;
    struct mysql_connect_entry  *next;
}Mysql_connect_entry;
class sql_pool
{
    private:
        Mysql_connect_entry     *g_ast_sqlconnect;
        Mysql_connect_entry     *connect_head;
        Mysql_connect_entry     *connect_tail;
        oal_uint16              g_ast_connect_num;
        pthread_spinlock_t      connect_get_lock;
        pthread_spinlock_t      connect_put_lock;
    public:
        string  mHost;
        string  mUser;
        string  mPassword;
        string  mDatabase;
        sql_pool()
        {
            g_ast_sqlconnect  = NULL;
            g_ast_connect_num = 0;
            pthread_spin_init(&connect_get_lock,PTHREAD_PROCESS_PRIVATE);
            pthread_spin_init(&connect_put_lock,PTHREAD_PROCESS_PRIVATE);
        }
        oal_bool       Init(string host, string user, string passwd, string database, oal_uint16 sql_num);
        mysqlconnect*  get_connect();
        oal_void       free_connect(mysqlconnect *used_connect);
};
extern sql_pool*   sqlpool;
#endif